import json
import yaml

def parser_files(file_path):
    with open(file_path,'r',encoding='utf-8') as f:
        if '.yaml' in file_path:
            return yaml.safe_load(f)
        elif '.json' in file_path:
            return json.load(f)
        else:
            f.read()
def write_files(file_path,data):
    with open(file_path,'w',encoding='utf-8') as f:
        if '.yaml' in file_path or '.yaml' in file_path:
            yaml.safe_dump(data,f,encoding='utf-8',allow_unicode=True)
        elif '.json' in file_path:
            json.dump(data,f,ensure_ascii=False)
        else:
            f.write(data)
if __name__ == '__main__':
    print(parser_files('D:\yuancheng_cangku\geren_daima\env\\test.yaml'))